package cn.edu.zhku.dto;

import cn.edu.zhku.pojo.Group;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class GroupDto extends BaseDto {
    @ApiModelProperty("群组名称")
    private String groupName;
    @ApiModelProperty("邀请码，唯一")
    private String inviteCode;
    @ApiModelProperty(value = "false表示可加入，true表示不可加入", example = "false")
    private Boolean forbidden;

    public Group getGroup() {
        Group group = new Group();
        group.setGroupId(this.groupId);
        group.setUserId(this.userId);
        if (this.groupName != null) group.setGroupName(this.groupName.trim());
        group.setInviteCode(this.inviteCode);
        if (forbidden != null) {
            if (forbidden)
                group.setForbidden(1);
            else
                group.setForbidden(0);
        }
        return group;
    }


}
